package com.thkj.modules.hik.controller;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import com.thkj.camera.CamerasRequest;
import com.thkj.camera.HikCamerasResoures;
import com.thkj.common.util.RequestUtil;
import com.thkj.modules.user.service.TblIndividualService;

import dp.R;
import dp.web.BaseAction;

/**
 * 海康控制器
 */
@RestController
@RequestMapping("/backstage/hikorigin")
public class HikOriginAction extends BaseAction {
	@Autowired
	TblIndividualService tblIndividualService;

	@RequestMapping("")
	public ModelAndView index() {
		return new ModelAndView("hikorigin/list");
	}

	@RequestMapping("/query")
	public R query(HttpServletRequest request) {
		Map<String, Object> param = RequestUtil.getParameterMap(request);
		System.out.println("huang===param==" + param.toString());
		String parentIndexCode = (String) param.get("parentIndexCode");
		String treeCode = (String) param.get("treeCode");
		String name = (String) param.get("searchStr");

		List<Map> list = HikCamerasResoures.getHikDistrictRes(parentIndexCode, treeCode, name);
		return R.success(list);
	}

	@RequestMapping("/districtList")
	public R districtList(HttpServletRequest request) {
		List<Map> list = HikCamerasResoures.getHikDistrict();
		return R.success(list);
	}

	@RequestMapping("/cameras")
	public R apply(@RequestParam("pageNo") Integer pageNo, @RequestParam("pageSize") Integer pageSize,
			@RequestParam("regionIndexCode") String regionIndexCode) {
		CamerasRequest camerasRequest = new CamerasRequest();
		camerasRequest.setPageNo(pageNo);
		camerasRequest.setPageSize(pageSize);
		camerasRequest.setRegionIndexCode(regionIndexCode);
		List<Map> maps = HikCamerasResoures.getCameras(camerasRequest);
		if (maps == null || maps.size() == 0) {
			return R.failure("没有监控点");
		}
		return R.success(maps);
	}

}